<?

include_once "rbns_exception.php5"; 


class RBNS_base extends RBNS_exception{

function __construct() {
  
   parent::__construct();
}



//Utils Data methods


function prepaRequest($txt,$act="TFAHC"){
/*
  // removes trash from text string, convert some chars
// actions:
// T - trim
// N - NL 2 BR + Trim
// S - addslashes()
// B - BR 2 SPACE
// A - back ap - ` to &#96;
// D - back ap -  &#96; to `
// C - conv ` to &#39;
// E - conv  &#39; to '
// H - strip ALL tags
// F - escape all chars
// U -urlencode
// P - allow php code <?
*/
      $act = "".$act;
	  if(is_array($txt)) {
	  	 foreach($txt as $k=>$v)  {
	    	$txt[$k]=$this->prepaRequest($v,$act);
	     };
	  return $txt;
	  };

	  $txt = stripslashes($txt);


// P - allow php code <?

        if(strpos($act,'P')===false)
        {
	    	$txt = str_replace('<?',"&lt;?",$txt);
	    	$txt = str_replace('?>',"?&gt;",$txt);
	    };

// T - trim
        if (strpos($act,'T')!==false||strpos($act,'N')!==false) { $txt = trim($txt);}
// B - BR 2 SPACE
        if (strpos($act,'B')!==false) {
			$txt = preg_replace('/\015\012/','',$txt);
			$txt = str_replace('<br />',"\n",$txt);
		}

// H - strip ALL tags
        if (strpos($act,'H')!==false) {
        	$txt= str_replace('{?',"<",$txt);
        	$txt= str_replace('?}',">",$txt);
        	$txt = strip_tags($txt);
        }
 // N - NL 2 BR + Trim
        if (strpos($act,'N')!==false) {
			$txt = nl2br($txt);
			$txt = preg_replace('/\015\012/','',$txt);

		}
        if (strpos($act,'F')!==false) {	$txt = htmlspecialchars($txt);}
        if (strpos($act,'A')!==false) {	$txt = str_replace('`','&#96;',$txt);}
        if (strpos($act,'D')!==false) {	$txt = str_replace('&#96;','`',$txt);}
        if (strpos($act,'C')!==false) {	$txt = str_replace("'",'&#39;',$txt);}
        if (strpos($act,'E')!==false) {	$txt = str_replace('&#39;',"'",$txt);}
		if (strpos($act,'U')!==false) {	$txt = urlencode($txt);}
        if (strpos($act,'S')!==false) {	$txt = addslashes($txt);}
	return $txt;

}








// for pager methods

function setPerPage($perpage=5){
    if((int)$perpage!=0) $this->perpage=(int)$perpage;
 	else  		 		$this->perpage=($this->perpage)?$this->perpage:5;
}

function setPSL($page){

	if((int)$page>0)   $this->psl=(int)$page;
    else  	   	$this->psl=0;
}


} 

?>